<include file="Public:header" />
<!--主体内容-->
<!--左边-->
<div class="centent_box">
    <include file="Public:left" />
    <!--右边-->
    <div class="centent_right_box">
        <div class="centent_right rightCon">
            <div class="Mtitle">
                <ul>
                    <li class="on"><span>房源管理</span></li>
                </ul>
                <div class="rightWord"><a href="{:U('used/add')}">新增房源</a> &gt;&gt; 数据录入</div>
            </div>
            <form id="info_form" action="{:U('Used/manual')}" method="post" enctype="multipart/form-data">
                <div class="con_div">
                    <ul class="formList width2 list_ul list_mp">
                        <li>
                            <label>房源属性：</label>
                            <select class="selectStyle" name="data[sell_type]" id="sell_type">
                                <option value="3">租售</option>
                                <option value="1">出售</option>
                                <option value="2">出租</option>
                            </select>
                        </li>

                        <li>
                            <label>房源名称：</label>
                            <input type="text"  name="data[title]" class="inputStyle width3" value="{$title}">
                        </li>
                        <li class="clear" id="area-sele">
                            <empty name="eid">
                                <label>区域范围：</label>
                                <select class="selectStyle" name="area" id="area" onclick="getArea(this)" onchange="seleArea(this)">
                                    <option value="0">--请选择--</option>
                                    <option value="1">深圳</option>
                                </select>
                            </empty>
                            <input type="hidden" name="data[area_id]" id="res-area" >
                            <input type="hidden" name="data[estate_id]" value="{$eid}">
                        </li>
                        <li>
                            <label>房源编码：</label>
                            <input type="text"  name="data[encoded]" id="encoded" class="inputStyle width3" >
                        </li>
                        <li>
                            <label>房屋信息：</label>
                            <input type="number"  name="build[build]"  class="inputStyle" min="1" style="width:70px">
                            <span class="tip">栋</span>
                            <input type="number"  name="unit[unit]" class="inputStyle" min="1" style="width:70px" value="1">
                            <span class="tip">单元</span>
                            <input type="number"  name="data[floor]" class="inputStyle" min="1" style="width:70px" >
                            <span class="tip">楼层</span>
                            <input type="number"  name="room[room]" class="inputStyle" style="width:70px">
                            <span class="tip">房号</span>
                        </li>
                        <li>
                            <label></label>
                            <input type="text"  name="build[alias]"  class="inputStyle" style="width:50px">
                            <span class="tip">栋(名称)</span>
                            <input type="text"  name="unit[alias]" class="inputStyle" style="width:50px">
                            <span class="tip">单元(名称)</span>
                            <input type="text"  name="room[f_alias]" class="inputStyle" style="width:50px">
                            <span class="tip">楼层(名称)</span>
                            <input type="text"  name="room[alias]" class="inputStyle" style="width:50px">
                            <span class="tip">房号(名称)</span>
                            <input type="number"  name="build[height]" class="inputStyle" style="width:50px" min="1">
                            <span class="tip">总楼层</span>
                        </li>
                        <li>
                            <label>选择户型：</label>
                            <input type="number"  name="data[chamber]" value="{$room.chamber}" class="inputStyle used_type" style="width: 70px" min="0" max="100" value="1">
                            <span class="tip">室</span>
                            <input type="number"  name="data[hall]" value="{$room.hall}" class="inputStyle used_type" style="width: 70px" min="0" max="100" value="0">
                            <span class="tip">厅</span>
                            <input type="number"  name="data[toilet]" value="{$room.toilet}" class="inputStyle used_type" style="width: 70px" min="0" max="5" value="0">
                            <span class="tip">卫</span>
                            <input type="number"  name="data[kitchen]" value="{$room.kitchen}" class="inputStyle used_type" style="width: 70px" min="0" max="5" value="0">
                            <span class="tip">厨</span>
                            <input type="number"  name="balcony"  class="inputStyle used_type" style="width: 50px" min="0" max="5">
                            <span class="tip">阳台</span>
                        </li>
                        <li class="dict-info">
                            <label>面积：</label>
                            <input type="text" class="inputStyle width2 required" name="room[area]" value="{$room.area}" data="{$room.area}" id="proportion" >
                            <span class="tip">平方米</span>

                        </li>
                        <li id="li-total">
                            <label>售价：</label>
                            <input type="text" class="inputStyle width2 required" name="data[total_price]" id="total" placeholder="万元">
                            <span class="tip">万元</span>
                            <label class="label1">均价：</label>
                            <input type="text" class="inputStyle width2" name="data[average_price]"  placeholder="元/平方米" id="average" readonly>
                            <span class="tip">元/平方米</span>
                        </li>
                        <li id="li-rental">
                            <label>租金：</label>
                            <input type="text" class="inputStyle width2 required" name="data[rental_price]" id="rental">
                            <span class="tip">元/月</span>
                            <!--label class="label1">均价：</label>
                            <input type="text" class="inputStyle width2" name="data[average_rental]"  placeholder="元/平方米" id="average_rental" readonly>
                            <span class="tip">元/平方米</span-->
                        </li>
                        <li>
                            <label>联系人 ：</label>
                            <input type="text" class="inputStyle width1 required" name="data[contacts]">
                            <span class="tip">必填项</span>
                        </li>
                        <li>
                            <label>联系电话：</label>
                            <input type="text" class="inputStyle required ismobile" name="data[phone]" >
                            <span class="tip">必填项</span>
                            <button onclick="addPhone (this)" id="btu-phone">新增</button>
                        </li>
                        <li style="display: none;" id="phone-other">
                            <label>其它电话：</label>
                            <input type="text" class="inputStyle required ismobile" name="data[phone1]" style="width:150px;margin-right: 20px;display: none" id="phone1">
                            <input type="text" class="inputStyle required ismobile" name="data[phone2]" style="width:150px;margin-right: 20px;display: none" id="phone2">
                            <input type="text" class="inputStyle required ismobile" name="data[phone3]" style="width:150px;margin-right: 20px;display: none" id="phone3">
                        </li>
                        <li class="li_radio">
                            <label class="lw90">朝向：</label>
                            <input type="radio" name="room[aspect]" id="orientations109" value="10" <if condition="$room['aspect'] eq 10">checked</if> >
                            <label for="orientations109">西北</label>
                            <input type="radio" name="room[aspect]" id="orientations108" value="9" <if condition="$room['aspect'] eq 9">checked</if> >
                            <label for="orientations108">西南</label>
                            <input type="radio" name="room[aspect]" id="orientations107" value="8" <if condition="$room['aspect'] eq 8">checked</if> >
                            <label for="orientations107">东北</label>
                            <input type="radio" name="room[aspect]" id="orientations106" value="7" <if condition="$room['aspect'] eq 7">checked</if> >
                            <label for="orientations106">东南</label>
                            <input type="radio" name="room[aspect]" id="orientations105" value="6" <if condition="$room['aspect'] eq 6">checked</if> >
                            <label for="orientations105">南北</label>
                            <input type="radio" name="room[aspect]" id="orientations104" value="5" <if condition="$room['aspect'] eq 5">checked</if> >
                            <label for="orientations104">东西</label>
                            <input type="radio" name="room[aspect]" id="orientations103" value="4" <if condition="$room['aspect'] eq 4">checked</if> >
                            <label for="orientations103">北</label>
                            <input type="radio" name="room[aspect]" id="orientations102" value="3" <if condition="$room['aspect'] eq 3">checked</if> >
                            <label for="orientations102">南</label>
                            <input type="radio" name="room[aspect]" id="orientations101" value="2" <if condition="$room['aspect'] eq 2">checked</if> >
                            <label for="orientations101">西</label>
                            <input type="radio" name="room[aspect]" id="orientations100" value="1" <if condition="$room['aspect'] eq 1">checked</if> >
                            <label for="orientations100">东</label>
                        </li>
                        <li class="li_checkbox" id="mating">
                            <label class="lw90">房屋配套：</label>
                            <input type="checkbox" name="mating[]" id="mating1" value="1"><label for="mating1">冰箱</label>
                            <input type="checkbox" name="mating[]" id="mating2" value="2"><label for="mating2">床</label>
                            <input type="checkbox" name="mating[]" id="mating3" value="3"><label for="mating3">衣橱</label>
                            <input type="checkbox" name="mating[]" id="mating4" value="4"><label for="mating4">热水器</label>
                            <input type="checkbox" name="mating[]" id="mating5" value="5"><label for="mating5">沙发</label>
                            <input type="checkbox" name="mating[]" id="mating6" value="6"><label for="mating6">电视</label>
                            <input type="checkbox" name="mating[]" id="mating7" value="7"><label for="mating7">网络</label>
                            <input type="checkbox" name="mating[]" id="mating8" value="8"><label for="mating8">家电齐全</label>
                            <input type="checkbox" name="mating[]" id="mating9" value="9"><label for="mating9">家私齐全</label>
                        </li>
                        <if condition="$room['img'] neq null">
                            <li style="height: 220px" id="used-type">
                                <label>户型图：</label>
                                <div style="display:inline-table;width: 200px;height: 200px">
                                    <img src="{$room.img}" width="200px" height="200px"/>
                                </div>
                                <button onclick="alter (this)">修改</button>
                            </li>

                            <else />
                            <li>
                                <label>户型图：</label>
                                <input type="file" name="img" id="img">
                            </li>

                        </if>
                        <li>
                            <label>产权：</label>
                            <select name="data[property]" id="property" class="selectStyle">
                                <option value="0" selected>请选择</option>
                                <option value="15">红本五年一套</option>
                                <option value="16">红本两年多套</option>
                                <option value="17">贷款五年一套</option>
                                <option value="18">贷款两年多套</option>
                                <option value="19">贷款不满两年</option>
                                <option value="21">红本不满两年</option>
                                <option value="12">红本在手</option>
                            </select>
                            <label>用途：</label>
                            <select name="data[purpose]" id="purpose" class="selectStyle">
                                <option value="0" selected>请选择</option>
                                <option value="1">居住</option>
                                <option value="2">写字楼</option>
                                <option value="3">商铺</option>
                                <option value="4">商务公寓</option>
                                <option value="5">厂房</option>
                            </select>
                        </li>
                        <li>
                            <label>钥匙人 ：</label>
                            <select name="data[keyer]" id="keyer" class="selectStyle">
                                <option value="">请选择</option>
                                <volist name="users" id="vo">
                                    <option value="{$vo.id}">{$vo.username}</option>
                                </volist>
                            </select>
                            <label>钥匙编号 ：</label>
                            <input type="text" class="inputStyle width1" name="data[keyno]">
                        </li>
                        <li>
                            <label>维护人 ：</label>
                            <select name="data[maintain]" id="maintain" class="selectStyle">
                                <option value="">请选择</option>
                                <volist name="users" id="vo">
                                    <option value="{$vo.id}" {$vo.sele}>{$vo.username}</option>
                                </volist>
                            </select>
                        </li>
                        <li id="files">
                            <label>多图上传：</label>
                            <script id="uploadpic" name="uploadpic" type="text/plain"></script>
                            <input type="button" class="btn btn_submit" style="margin:0 0 10px 10px;" onclick="upImage();" value="选择图片">
                            <div id="imageList">
                                <ul class="list clearfix"></ul>
                            </div>
                            <input type="hidden" name="file" id="file" />
                        </li>
                        <li class="li_radio">
                            <label class="lw90">装修情况：</label>
                            <input type="radio" name="room[decorate]" id="renovation_type70" value="4"><label for="renovation_type70">豪装</label>
                            <input type="radio" name="room[decorate]" id="renovation_type68" value="3"><label for="renovation_type68">精装</label>
                            <input type="radio" name="room[decorate]" id="renovation_type67" value="2"><label for="renovation_type67">简装</label>
                            <input type="radio" name="room[decorate]" id="renovation_type69" value="1"><label for="renovation_type69">毛坯</label>
                        </li>
                        <li>
                            <label>建筑年代：</label>
                            <input type="text" class="inputStyle width2" name="data[years]" value="{$estate.years}" id="years">
                            <span class="tip">年</span>
                        </li>
                        <li>
                            <label>所在地址：</label>
                            <input type="text" class="inputStyle width3" name="data[address]" value="{$estate.address}" id="addr">
                            <span class="tip">中文字符</span>
                        </li>
                        <li>
                            <label>地图标注：</label>
                            <input type="text" class="inputStyle" name="data[map]" id="map" value="{$estate.map}">
                            <span class="tip"><a target="_blank" style="padding: 4px 8px;color:#ffffff;background: orange" href="http://api.map.baidu.com/lbsapi/getpoint/">获取百度地图坐标</a></span>
                        </li>

                        <li class="height1">
                            <label>特色标签：</label>
                            <textarea class="textarea" style="width: 550px;float: left" id="tags" name="data[tags]"></textarea>
                            <span class="tip">多个使用,号隔开</span>
                        </li>

                        <li class="height2">
                            <label>详细介绍：</label>
                            <textarea name="data[info]" id="info" style="width:100%;height:300px;resize: none;float:left"></textarea>
                        </li>
                        <input type="hidden"  name="data[img]" id="img-url">
                        <li>
                            <label></label>
                            <input type="submit" value="提 交" class="btnStyle">
                        </li>
                    </ul>
                </div>
            </form>
        </div>
    </div>
</div>
<js file="__S__/ueditor/ueditor.config.js" charset="utf-8" />
<js file="__S__/ueditor/ueditor.all.min.js" charset="utf-8" />
<js file="__S__/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" />
<js file="__JS__/uploadImg.js" charset="utf-8" />
<script type="text/javascript">
    window.UEDITOR_HOME_URL='__STATIC__/ueditor/';
    window.onload=function(){
        window.UEDITOR_CONFIG.initialFrameWidth=880;
        window.UEDITOR_CONFIG.initialFrameHeight=500;
        upmoreimg();
    }
    var ue = UE.getEditor('info', {
        toolbars: [[
            'fullscreen', 'source', '|',
            'bold', 'italic', 'underline', '|', 'fontfamily','fontsize', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', 'simpleupload','|', 'kityformula', 'preview'
        ]]
    });
</script>
<script src="__S__/js/ajaxfileupload.js"></script>
<script src="__S__/js/jquery.validate.js"></script>
<script src="__S__/js/magess.js"></script>
<script src="__S__/js/jquery.metadata.js"></script>
<script type="text/javascript">
    $().ready(function() {
        $("#info_form").validate();
        jQuery.validator.addMethod("ismobile", function(value, element) {
            var length = value.length;
            var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
            return this.optional(element) || (length == 11 && mobile.test(value));
        }, "请正确填写您的手机号码");
    });

</script>
<script>
    $("#sell_type").change (function (){
        var id = $(this).val();
        if (id == 1){
            $('#li-rental').hide();
            $('#li-total').show();
        }
        if (id == 2){
            $('#li-rental').show();
            $('#li-total').hide();
        }
        if (id == 3){
            $('#li-rental').show();
            $('#li-total').show();
        }
    });
    //新增电话号码
    function addPhone (tar){
        event.preventDefault();//阻制默认事件
        window.event.returnValue;
        layer.open({
            type: 1,
            area: ['300px', ''],
            anim: 2,
            content: '<div style="margin-top: 20px"><ul class="formList list_ul clear">' +
            '<li><label>手机号：</label><input type="number" name="phone1" class="inputStyle width2 ismobile" /></li>' +
            '</ul><div style="margin:50px 10px 10px 100px">' +
            '<button onclick="phone(this)">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
            '<button onclick="javascripy:layer.closeAll()">取消</button>' +
            '</div></div>'
        });
    }
    var phoneCount = 0;
    function phone (tar){
        var phone = $('input[name=phone1]').val();
        phoneCount += 1;
        if (phoneCount > 3){
            layer.msg('最多只能添加3个号码', {icon: 0});
            return false;
        }
        $('#phone-other').show ();
        $('#phone'+phoneCount).show ();
        $('#phone'+phoneCount).val(phone);
        layer.closeAll();
    }
    $('#total').keyup(function(){
        var total = $(this).val();console.log(total);
        var area = $('#proportion').val();console.log(area);
        var average = parseFloat(total)/parseFloat(area)*10000;
        $('#average').val(average.toFixed(2));
    })
    function alter (tar){
        event.preventDefault();
        window.event.returnValue;
        var prevElem = $('#used-type').prev('li');
        $('#used-type').remove();
        prevElem.after('<li><label>户型图：</label><input type="file" name="img" id="img"></li>')
        layer.closeAll();

    }
    //选择区域
    function getArea (tar){
        var areaid = $(tar).val();
        var sele = $(tar);
        if (areaid == 0) {
            $(sele).nextAll('select').remove();
            return false;
        }
        var url = "{:U('Ajax/getArea')}", data = {areaid:areaid};
        $.post (url, data, function (response){
            var html = '';
            if (response.state == 'ok'){
                var data = response.data;
                html = '<select class="selectStyle" name="area" onclick="getArea(this)" onchange="seleArea(this)"><option value="0">--请选择--</option>';
                $.each(data, function (i, v){
                    html += '<option value="'+v.id+'">'+v.name+'</option>';
                });
                html += '</select>';
            }
            console.log($(sele));
            $(sele).nextAll('select').remove();
            $('#area-sele').append(html);
        }, 'json');
    }
    function seleArea(tar) {
        var sele_val = $(tar).val();
        $('#res-area').val(sele_val);
    };
</script>
<include file="Public:footer" />